#include "config.h"

#include "ms2lstat.h"

#ifdef MSM_DEBUG

const char *
dbg_lent(lent_t *lent, session_t *session)
{
	static char	buf[2048];

	media_t	*media;

	media = get_media(lent->mid);
	ecm_snprintf(buf, 2048, "sid:%u mlen:%u %u %u %d",
		     session->sid,
		     media->length,
		     lent->startstamp,
		     lent->duration,
		     lent->playback_rate);

	return buf;
}

#if 0 ///TODO

const char *
dbg_forward_log(lent_t *lent, session_t *session)
{
	static char	buf[2048];
	access_t	*access_last;
	ecm_uint64	tick_last;
	ecm_uint32	tick_diff;
	ECMBOOL		forward_early;
	media_t	*media;

	media = get_media(lent->mid);
	if (list_empty(&session->accesses)) {
		ecm_snprintf(buf, 2048, "sid:%u mlen:%u forward:%u-%u",
			     session->sid, media->length,
			     lent->startstamp, lent->duration
			     lent->duration / 1000);
		return buf;
	}

	access_last = list_entry(session->accesses.prev, access_t, list);
	tick_last = access_last->tick_start + access_last->duration;
	if (lent->tick >= tick_last) {
		forward_early = ECM_FALSE;
		tick_diff = lent->tick - tick_last;
	}
	else {
		forward_early = ECM_TRUE;
		tick_diff = tick_last - lent->tick;
	}
		
	ecm_snprintf(buf, 2048, "sid:%u mlen:%u prev:%u-%u forward:%u-%u %s%u",
		     session->sid,
		     media->length,
		     access_last->startstamp /1000,
		     (access_last->startstamp + access_last->duration) / 1000,
		     lent->startstamp / 1000,
		     lent->duration / 1000,
		     forward_early ? "-": "",
		     tick_diff / 1000);
	return buf;
}
#endif

#endif
